package com.system.AttendanceCherkDepartment.web;



import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.system.AttendanceCherkDepartment.entity.Attendance;
import com.system.AttendanceCherkDepartment.service.IAttendanceService;
import com.system.common.util.ExtAjaxResponse;
import com.system.common.util.ExtPageable;






@Controller
@RequestMapping("/attendance")
public class AttendanceController {

	@Autowired
	private IAttendanceService attendanceService;
	@RequestMapping("/findAllById")
	public @ResponseBody Page<Attendance> findAllById(ExtPageable extPageable) 
	{
		Long empId=12L;////传前端数据
			//List<Attendance> list=(List<Attendance>) attendanceService.findAll(12L,null);
			return attendanceService.findAll(empId,extPageable.getPageable());
	}
	
	@RequestMapping("/findOneById")
	public @ResponseBody Attendance findOne() {
		Long empId=12L;////传前端数据
		return attendanceService.findOne(empId);
	}
	
	@RequestMapping("/delete")
	public @ResponseBody ExtAjaxResponse delete(Long id) {
		try {
			Attendance training=attendanceService.findOne(id);
			if(null!=training) {
				attendanceService.delete(training);
			}
			return new ExtAjaxResponse(true,"操作成功！");
		} catch (Exception e) {
			return new ExtAjaxResponse(false,"操作失败！");
		}
	}
	
	@RequestMapping("/deleteAttendance")
	public @ResponseBody ExtAjaxResponse deleteAttendances(@RequestParam Long[] ids) {
		try {
			List<Long> lists=Arrays.asList(ids);
			if(null!=lists) {
				attendanceService.deleteAttendances(lists);
			}
			return new ExtAjaxResponse(true,"操作成功！");
		} catch (Exception e) {
			return new ExtAjaxResponse(false,"操作失败！");
		}
	}

	
	
}
